import { IPSLanguageRes } from '../res/ipslanguage-res';
import { IPSSystemModule } from '../system/ipssystem-module';
import { IPSWFDE } from './ipswfde';
import { IPSWFVersion } from './ipswfversion';
import { IPSWorkflow } from './ipsworkflow';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSWorkflowImpl extends PSModelObjectImpl implements IPSWorkflow {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get entityWFCancelState(): string {
    return this.M.entityWFCancelState;
  }

  get entityWFErrorState(): string {
    return this.M.entityWFErrorState;
  }

  get entityWFFinishState(): string {
    return this.M.entityWFFinishState;
  }

  get entityWFState(): string {
    return this.M.entityWFState;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected namepslanguageres: IPSLanguageRes | null = null;

  getNamePSLanguageRes(): IPSLanguageRes | null {
    if (this.namepslanguageres != null) return this.namepslanguageres;
    const value = this.M.getNamePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.namepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getNamePSLanguageRes') as IPSLanguageRes;
    return this.namepslanguageres;
  }

  get namePSLanguageRes(): IPSLanguageRes | null {
    return this.getNamePSLanguageRes();
  }

  getNamePSLanguageResMust(): IPSLanguageRes {
    const value = this.getNamePSLanguageRes();
    if (value == null) {
      throw new Error('未指定名称语言资源');
    }
    return value;
  }

  protected pssystemmodule: IPSSystemModule | null = null;

  getPSSystemModule(): IPSSystemModule | null {
    if (this.pssystemmodule != null) return this.pssystemmodule;
    const value = this.M.getPSSystemModule;
    if (value == null) {
      return null;
    }
    this.pssystemmodule = this.getPSModel4('system.IPSSystemModule', value, 'getPSSystemModule') as IPSSystemModule;
    return this.pssystemmodule;
  }

  get psSystemModule(): IPSSystemModule | null {
    return this.getPSSystemModule();
  }

  getPSSystemModuleMust(): IPSSystemModule {
    const value = this.getPSSystemModule();
    if (value == null) {
      throw new Error('未指定系统模块');
    }
    return value;
  }

  protected pswfdes: IPSWFDE[] | null = null;

  getPSWFDEs(): IPSWFDE[] | null {
    if (this.pswfdes == null) {
      this.pswfdes = this.fillChildListModel(this.M.getPSWFDEs, 'wf.IPSWFDE') as IPSWFDE[];
    }
    return this.pswfdes;
  }

  get psWFDEs(): IPSWFDE[] | null {
    return this.getPSWFDEs();
  }

  findPSWFDE(objKey: any): IPSWFDE | null {
    return this.getPSModel5('wf.IPSWFDE', this.getPSWFDEs(), objKey) as IPSWFDE;
  }

  protected pswfversions: IPSWFVersion[] | null = null;

  getPSWFVersions(): IPSWFVersion[] | null {
    if (this.pswfversions == null) {
      this.pswfversions = this.fillChildListModel(this.M.getPSWFVersions, 'wf.IPSWFVersion') as IPSWFVersion[];
    }
    return this.pswfversions;
  }

  get psWFVersions(): IPSWFVersion[] | null {
    return this.getPSWFVersions();
  }

  findPSWFVersion(objKey: any): IPSWFVersion | null {
    return this.getPSModel5('wf.IPSWFVersion', this.getPSWFVersions(), objKey) as IPSWFVersion;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get wFEngineCat(): string {
    return this.M.wFEngineCat;
  }

  get wFEngineType(): string {
    return this.M.wFEngineType;
  }

  get wFProxyMode(): 0 | 1 | 2 | 3 {
    return this.M.wFProxyMode;
  }

  get wFSN(): string {
    return this.M.wFSN;
  }

  get wFType(): 'ORG' | 'ORGSECTOR' | 'DEFAULT' {
    return this.M.wFType;
  }

  get useRemoteEngine(): boolean {
    return this.M.useRemoteEngine;
  }

  get useWFProxyApp(): boolean {
    return this.M.useWFProxyApp;
  }

  get valid(): boolean {
    return this.M.valid;
  }

  get cls(): string {
    return 'PSWorkflowImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'wf.IPSWorkflow') return true;
    return super.instanceof(cls);
  }
}
